package org.example.Test;

import org.example.persistence.model.reportSub;
import org.jasypt.encryption.pbe.StandardPBEStringEncryptor;
import org.jasypt.iv.NoIvGenerator;
import org.apache.commons.beanutils.PropertyUtils;
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Matcher;
import org.apache.commons.text.CaseUtils;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

public class Test {
//    public static void main(String[] args) {
//
//        //jasypt加解密
//        StandardPBEStringEncryptor s = new StandardPBEStringEncryptor();
//        s.setAlgorithm("PBEWithMD5AndDES");
//        s.setIvGenerator(new NoIvGenerator());
//        s.setPassword("11613216");
//        String encrypt = s.encrypt("1");
//
//        System.out.println(encrypt);
//
////        String decrypt = s.decrypt("加密后");
//    }
    public static int countDivisions(int number, int divisor) {
        int count = 0;
        while (number >= divisor) {
            number = number / divisor;
            count++;
        }
        return count;
    }

    public static void main(String[] args) {
//        int number = 1008;
//        int divisor = 10;
//        int result = countDivisions(number, divisor);
//        System.out.println("被除几次: " + result);
//
//        String a ="a,\n" +
//                "b,\n" +
//                "c,\n" +
//                "d,\n" +
//                "";
//        System.out.println(a);
//        a=a.replaceFirst(",(?!.*,)", "");
//        System.out.println(a); // 输出：a,b,c,d,e
//
//
//        // 获取当前时间的毫秒数
//        long currentTimeMillis = System.currentTimeMillis();
//
//        // 打印当前时间的毫秒数
//        System.out.println("当前时间的毫秒数：" + currentTimeMillis);
//
//
//        reportSub obj = new reportSub();
//        obj.setReportNum("12345");
//
//        String fieldName = "reportNum";
//        Object value = null;
//
//        try {
//            value = PropertyUtils.getProperty(obj, fieldName);
//        } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
//            e.printStackTrace();
//        }
//
//        System.out.println("Field Name: " + fieldName);
//        System.out.println("Field Value: " + value);


        String a = "CG_ID_NAME".toLowerCase();
        Pattern pattern = Pattern.compile("_(\\w)");
        Matcher matcher = pattern.matcher(a);
        StringBuffer sb = new StringBuffer();
        while (matcher.find()) {
            matcher.appendReplacement(sb, matcher.group(1).toUpperCase());
        }
        matcher.appendTail(sb);
        String result = sb.toString().replaceAll("_", "");
        System.out.println(result);


        String columnName = "CG_ID_FG_IJ_KOIOH";
        String camelCaseName = CaseUtils.toCamelCase(columnName, false, '_');
        System.out.println("--------"+camelCaseName);
    }


    public static String replaceLastComma(String input) {
        return input.replaceFirst(",(?!.*,)", "");
    }


}
